﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="UserPaperList.aspx.cs" Inherits="OnLineExam.Web.mag.UserPaperList" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title></title>
    <link href="../jquery-easyui-1.2.5/themes/default/easyui.css" rel="stylesheet" type="text/css" />
    <link href="../jquery-easyui-1.2.5/themes/icon.css" rel="stylesheet" type="text/css" />
    <script src="../jquery-easyui-1.2.5/jquery-1.7.1.min.js" type="text/javascript"></script> 
    <script src="../jquery-easyui-1.2.5/jquery.easyui.min.js" type="text/javascript"></script>
    <script src="../Scripts/jQuery.FillOptions.js" type="text/javascript"></script>
    <script src="../jquery-easyui-1.2.5/locale/easyui-lang-zh_CN.js" type="text/javascript"></script>
    <script type="text/javascript"><!--
        $(function () {
            $("#selectDep").FillOptions('GetDepInfoHandler.ashx?c=' + new Date().getMilliseconds() + '&type=getlist&depid=<%=Umodel.DepID %>', { datatype: "json", textfield: "Name", valuefiled: "ID" });
            $("#selectCourse").FillOptions('GetCourseHandler.ashx?c=' + new Date().getMilliseconds() + '&type=getlist&depid=<%=Umodel.DepID %>', { datatype: "json", textfield: "CourseName", valuefiled: "CourseID" });
            <%if (User.IsInRole("教师")){ %>
                $("#dd table tr").eq(0).hide();
                        //$("#selectDep").attr("disabled", 'disabled'); //默认选中disabled
                        <%} %>
            $("#selectDep").change(function () {
            $("#selectCourse").empty();
             $("#selectCourse").FillOptions('GetCourseHandler.ashx?c=' + new Date().getMilliseconds() + '&type=getlist&depid='+$("#selectDep").val(), { datatype: "json", textfield: "CourseName", valuefiled: "CourseID" });
             });

            $('#tt').datagrid({

                idField: 'ID',
                url: 'Handler/PaperHandler.ashx?c=' + new Date().getMilliseconds() + '&type=getlist&depid=<%=Umodel.DepID %>', //?startIndex=0&endIndex=20  /''+ index +'/'
                singleSelect: true,
                columns: [[
                   { field: 'PaperID', title: 'ID' },
                  { field: 'PaperName', title: '试卷名称', width: 250 },
                  { field: 'startExamTime', title: '开始时间', width: 80 },
                  { field: 'EndExamTime', title: '结束时间', width: 80 },
                  { field: 'ExamTime', title: '考试时长', width: 80 },
                  { field: 'allowExamNum', title: '允许次数', width: 80 },
                  { field: 'passMark', title: '及格分数', width: 80 },

                  { field: 'opt', title: '操作', width: 100, align: 'center',
                      formatter: function (value, rec, index) {
                          var e = '<a href="#" mce_href="#" onclick="edit(' + rec.PaperID + ')">编辑</a> ';
                          var d = '<a href="#" mce_href="#" onclick="del(' + index + ')">删除</a> ';
                          return e + d;
                      }
                  }
                ]],
                toolbar: [{
                    text: '增加', iconCls: 'icon-add', handler: function () {
                    $("#selectDep").attr("value",'<%=Umodel.DepID %>');
                    //$("#selectCourse").attr("value", obj.CourseID);
                    $("#txtPaperName").val("");
                    $("#txtStartDateTime").val("");
                    $("#txtEndDateTime").val("");
                    $("#txtExamTime").val("");
                    $("#txtallowExamNum").val("");
                    $("#txtpassmark").val("");
                    $("#txtJoinEmpID").val("");
                     
                    $("#txtSingleNum").val("");
                    $("#txtSingleFen").val("");
                    $("#txtMultiNum").val("");
                    $("#txtMultiFen").val("");
                    $("#txtJudgeNum").val("");
                    $("#txtJudgeFen").val("");
                    $("#txtFillBlankNum").val("");
                    $("#txtFillBlankFen").val("");
                    $("#txtQuestionNum").val("");
                    $("#txtQuestionFen").val("");

                    $("#hdType").val("addsave");
                    $('#dd').dialog('open').dialog('setTitle', '制定新试卷' );
                    }
                } ,
                { text: '查找', iconCls: 'icon-search' }
                ],
                pagination: true, rownumbers: false
            }); 
        })


        function view(bh)  //转到查看页面
        {
            window.location.href = 'StuView.aspx?id=' + bh + '&page=stu';

        }
        function edit(bh)  //转到编辑页面
        { 
            $.ajax({
                type: "get",
                url: "Handler/PaperHandler.ashx?d=" + new Date().getMilliseconds() + "&type=edit&ID=" + bh,
                beforeSend: function (XMLHttpRequest) {
                    //ShowLoading();
                },
                success: function (data, textStatus) {
                    var obj = eval('(' + data.toString() + ')');

                    $("#selectDep").attr("value", obj.DepID);
                    $("#selectCourse").attr("value", obj.CourseID);
                    $("#hdType").val("editsave");
                    $("#hdID").val(bh); 
                    $("#txtPaperName").val(obj.PaperName);
                    $("#txtStartDateTime").val(obj.startExamTime);
                    $("#txtEndDateTime").val(obj.EndExamTime);
                    $("#txtExamTime").val(obj.ExamTime);
                    $("#txtallowExamNum").val(obj.allowExamNum);
                    $("#txtpassmark").val(obj.passMark);
                    $("#txtJoinEmpID").val(obj.joinemps);
                    var probleminfo=obj.ProblemInfo.split(",");
                    $("#txtSingleNum").val(probleminfo[0].split(":")[1]);
                    $("#txtSingleFen").val(probleminfo[0].split(":")[2]);

                    $("#txtMultiNum").val(probleminfo[1].split(":")[1]);
                    $("#txtMultiFen").val(probleminfo[1].split(":")[2]);

                    $("#txtJudgeNum").val(probleminfo[2].split(":")[1]);    
                    $("#txtJudgeFen").val(probleminfo[2].split(":")[2]);

                    $("#txtFillBlankNum").val(probleminfo[3].split(":")[1]);
                    $("#txtFillBlankFen").val(probleminfo[3].split(":")[2]);

                    $("#txtQuestionNum").val(probleminfo[4].split(":")[1]);
                    $("#txtQuestionFen").val(probleminfo[4].split(":")[2]);

                   
                    $("input[name='txtExamTime']").attr("value", obj.ExamTime);
                    $("input[name='txtallowExamNum']").attr("value", obj.allowExamNum);
                    $("input[name='txtpassmark']").attr("value", obj.passMark);

                    $("input[name='txtSingleNum']").attr("value", probleminfo[0].split(":")[1]);
                    $("input[name='txtSingleFen']").attr("value", probleminfo[0].split(":")[2]);

                    $("input[name='txtMultiNum']").attr("value", probleminfo[1].split(":")[1]);
                    $("input[name='txtMultiFen']").attr("value", probleminfo[1].split(":")[2]);

                    $("input[name='txtJudgeNum']").attr("value", probleminfo[2].split(":")[1]);
                    $("input[name='txtJudgeFen']").attr("value", probleminfo[2].split(":")[2]);

                    $("input[name='txtFillBlankNum']").attr("value", probleminfo[3].split(":")[1]);
                    $("input[name='txtFillBlankFen']").attr("value", probleminfo[3].split(":")[2]);

                    $("input[name='txtQuestionNum']").attr("value", probleminfo[4].split(":")[1]);
                    $("input[name='txtQuestionFen']").attr("value", probleminfo[4].split(":")[2]);
                    
                    $('#dd').dialog('open').dialog('setTitle', '编辑试卷--' + obj.PaperName);

                },
                complete: function (XMLHttpRequest, textStatus) {
                    //HideLoading();
                },
                error: function () {
                    //请求出错处理
                }
            });
           
            //window.location.href = 'StuEdit.aspx?id=' + bh;

        }
        

        function save() { 
        $('#ff').form('submit',{  
     url: 'Handler/PaperHandler.ashx?d=' + new Date().getMilliseconds() + '&type='+$("#hdType").val(),
    onSubmit: function(){  
         return $(this).form('validate');
        // do some check  
        // return false to prevent submit;  
    },  
    success:function(data){  
        if (data > 0) {
                        $.messager.alert('操作结果', "执行成功，编号为：" + data, 'info');
                        $('#dd').dialog('close')
                    }
    }  
});  
// submit the form  
//$('#ff').submit();  
$('#tt').datagrid('reload');

           // $("#ff").submit();
      }

        function del(index) {  //删除操作
            $.messager.confirm('确认', '确认删除?', function (row) {
                if (row) {
                    var selectedRow = $('#tt').datagrid('getSelected');  //获取选中行
                    $.ajax({
                        url: 'Handler/PaperHandler.ashx?type=del&id=' + selectedRow.PaperID,
                        //加了个type，作用是以后不管什么删除，都可以转到这个ashx中处理
                        success: function () { $.messager.alert('操作结果', "删除成功，编号为：" + selectedRow.PaperID, 'info');  }
                    });
                    $('#tt').datagrid('deleteRow', index);
                }
            })
}
// --></script>
</head>
<body><table id="tt"></table>
    <div id="dd" class="easyui-dialog" style=" height:700px; width:850px;padding:10px 20px" closed="true" buttons="#dd-buttons">  
      <form id="ff" method="post"> <input id="hdType" name="hdType" type="hidden" />
     <input id="hdID" name="hdID" type="hidden" /> 
     <input id="hdDepID" name="hdDepID" type="hidden" value='<%=Umodel.DepID %>' />
                <table style="width: 100%;" align="left">
                    <tr>
                        <td align="right">
                            部门：</td>
                        <td align="left" colspan="3">
                            <select id="selectDep" name="selectDep"  
                                name="state" style="width:200px;" required="true" >
                                <option></option>
                            </select></td>
                    </tr>
                    <tr>
                        <td align="right">
                            &nbsp;
                            试卷科目:</td>
                        <td align="left" colspan="3">
                            <select id="selectCourse" name="selectCourse" name="state" style="width:200px;" required="true" >
                                <option></option>
                            </select></td>
                    </tr>
                    <tr>
                        <td align="right">
                            &nbsp;
                            试卷名称：</td>
                        <td align="left" colspan="3">
                            <textarea id="txtPaperName" name="txtPaperName" class="easyui-validatebox" cols="50" name="S1" rows="2" required="true"></textarea>&nbsp;
                        </td>
                    </tr>
                    <tr>
                        <td align="right">
                            &nbsp;
                            开始日期：</td>
                        <td align="left">
                            <input class="easyui-datetimebox" id="txtStartDateTime" name="txtStartDateTime" required="true" value="3/4/2010 2:3:56" style="width:150px"></td>
                        <td align="right">
                            结束日期：
                        </td>
                        <td>
                            <input class="easyui-datetimebox" id="txtEndDateTime" name="txtEndDateTime" required="true" value="3/4/2010 2:3:56" style="width:150px">&nbsp;</td>
                    </tr>
                    <tr>
                        <td align="right"> &nbsp; 考试时长：</td>
                        <td align="left">
                            <input id="txtExamTime" name="txtExamTime" class="easyui-numberspinner" max="150" min="10" required="true" 
                                style="width:80px;" />分钟</td>
                        <td align="right">
                            可考试次数：</td>
                        <td>
                            <input id="txtallowExamNum" name="txtallowExamNum" class="easyui-numberspinner" max="10" min="1" required="true" 
                                style="width:80px;" /> 数字范围：1-10</td>
                    </tr>
                    <tr>
                        <td align="right"> 及格分数：</td>
                        <td align="left">
                            <input id="txtpassmark" name="txtpassmark" class="easyui-numberspinner" max="150" min="10" precision="0" required="true" 
                                style="width:80px;" /></td>
                        <td align="right">
                            &nbsp;</td>
                        <td>
                            &nbsp;</td>
                    </tr>
                    <tr>
                        <td align="right"> 选择参试人员：</td>
                        <td align="left" colspan="3" style="border-bottom-color: #C1DAD7">
                            &nbsp;</td>
                    </tr>
                    <tr>
                        <td align="right"> 参试人员：</td>
                        <td align="left" colspan="3">
                            <textarea id="txtJoinEmpID" name="txtJoinEmpID" class="easyui-validatebox" validType="minLength[5]" cols="65" name="S2" rows="5" required="true"></textarea></td>
                    </tr>
                    <tr>
                        <td align="right">&nbsp;</td>
                        <td align="left" colspan="3"  >
                            &nbsp;</td>
                    </tr>

                    <tr>
                        <td align="right"><strong>单选题</strong>：</td>
                        <td align="left" colspan="3"  >
                            题目数量：<input 
                                id="txtSingleNum" name="txtSingleNum" class="easyui-numberspinner" max="50" min="0" precision="0" 
                                required="true" style="width:80px;" />&nbsp;每题分数：<input 
                                id="txtSingleFen" name="txtSingleFen" class="easyui-numberspinner" max="50" min="0" precision="0" 
                                required="true" style="width:80px;"/> 说明：数量0到50正整数；分数0到50 允许2位小数</td>
                    </tr>

                   <tr>
                        <td align="right"><strong>多选题</strong>：</td>
                        <td align="left" colspan="3"  >
                            题目数量：<input 
                                id="txtMultiNum" name="txtMultiNum" class="easyui-numberspinner" max="50" min="0" precision="0" 
                                required="true" style="width:80px;"/>&nbsp;每题分数：<input 
                                id="txtMultiFen" name="txtMultiFen" class="easyui-numberspinner" max="50" min="0" precision="0" 
                                required="true" style="width:80px;"/> 说明：数量0到50正整数；分数0到50 允许2位小数</td>
                    </tr>
                    <tr>
                        <td align="right"><strong>判断题</strong>：</td>
                        <td align="left" colspan="3"  >
                            题目数量：<input 
                                id="txtJudgeNum" name="txtJudgeNum" class="easyui-numberspinner" max="50" min="0" precision="0" 
                                required="true" style="width:80px;"/>&nbsp;每题分数：<input 
                                id="txtJudgeFen" name="txtJudgeFen" class="easyui-numberspinner" max="50" min="0" precision="0" 
                                required="true" style="width:80px;"/> 说明：数量0到50正整数；分数0到50 允许2位小数</td>
                    </tr>

                    <tr>
                        <td align="right"><strong>填空题</strong>：</td>
                        <td align="left" colspan="3"  >
                            题目数量：<input 
                                id="txtFillBlankNum" name="txtFillBlankNum" class="easyui-numberspinner" max="50" min="0" precision="0" 
                                required="true" style="width:80px;"/>&nbsp;每题分数：<input 
                                id="txtFillBlankFen" name="txtFillBlankFen" class="easyui-numberspinner" max="50" min="0" precision="0" 
                                required="true" style="width:80px;"/> 说明：数量0到50正整数；分数0到50 允许2位小数</td>
                    </tr>

                   <tr>
                        <td align="right"><strong>问答题</strong>：</td>
                        <td align="left" colspan="3"  >
                            题目数量：<input 
                                id="txtQuestionNum" name="txtQuestionNum" class="easyui-numberspinner" max="50" min="0" precision="0" 
                                required="true" style="width:80px;"/>&nbsp;每题分数：<input 
                                id="txtQuestionFen" name="txtQuestionFen" class="easyui-numberspinner" max="50" min="0" precision="0" 
                                required="true" style="width:80px;"/> 说明：数量0到50正整数；分数0到50 允许2位小数</td>
                    </tr>
                    </table>
    </form>
</div>
<div id="dd-buttons">
		<a href="#" class="easyui-linkbutton" iconCls="icon-ok" onclick="save()">保存</a>

		<a href="#" class="easyui-linkbutton" iconCls="icon-cancel" onclick="javascript:$('#dd').dialog('close')">取消</a>

	</div>

 
</body>
</html>
